package com.hp.pai.comm;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

public class FileConfiguration {
	private static Logger logger = Logger.getLogger(FileConfiguration.class);
	private Properties properties;
	private FileInputStream fileInputStream;
	
	public FileConfiguration(String filePath) throws IOException{
		properties = new Properties();
		
		try {
			fileInputStream = new FileInputStream(filePath);
			properties.load(fileInputStream);
			fileInputStream.close();
		} catch (FileNotFoundException ex) {
			logger.error("读取属性文件" + filePath + "失败!请检查文件是否存在");
		} catch (IOException ex) {
			logger.error("装载文件" + filePath + "失败");
		}
	}
	
	public String getValue(String sKey){
		if (properties.keySet().contains(sKey)){
			String sValue = properties.getProperty(sKey);
			return sValue;
		}
		else {
			return "";
		}
	}
	
	
}
